package com.xulinhao.edu.controller;


import com.xulinhao.commonutils.R;
import com.xulinhao.edu.entity.subject.OneSubject;
import com.xulinhao.edu.service.SubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author xulinhao
 * @since 2021-08-17
 */
@RestController
@RequestMapping("/eduservice/subject")
@CrossOrigin
public class SubjectController {
    @Autowired
    private SubjectService service;

    // 添加课程分类
    // 获取上传过来的文件,把文件内容读取出来
    @PostMapping("addSubject")
    public R addSubject(MultipartFile file){
        // 上传过来的Excel文件
        service.saveSubject(file,service);
        return R.ok();
    }

    //课程分类列表(树形)
    @GetMapping("getAllSubject")
    public R getAllSubject(){
        List<OneSubject> list = service.getAllOneTwoSubject();
        return R.ok().data("list",list);
    }

}

